from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QWidget, QPushButton, QRadioButton, QCheckBox, QLabel, QLineEdit, QPlainTextEdit
from PyQt5.uic import loadUi

from base_api.HelloWorldClass import HelloWorld

"""
主窗口
"""


class HomeWindow:
    def __init__(self):
        # 加载ui文件创建ui对象
        self.window = loadUi('ui/home.ui')
        self.window: QWidget
        # 显示该窗口对象
        self.window.show()
        # 按钮，事件监听 绑定方法
        self.window.pushButton: QPushButton
        self.window.pushButton.clicked.connect(self.pushButton_clicked)

    def pushButton_clicked(self):
        # 读取文本框内容
        self.window.lineEdit: QLineEdit
        s = self.window.lineEdit.text()
        # 创建任务对象
        helloWorld = HelloWorld()
        helloWorld.name = s
        # 输出
        self.window.plainTextEdit: QPlainTextEdit
        self.window.plainTextEdit.setPlainText(helloWorld.say())
